[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
strlen() Get String Length
#include <string.h>
size_t strlen(string);
const char *string;
strlen() gets the length of 'string'. The terminating null character
('\0') is not included in the length.
Returns: The string length. A length of zero means the string
is empty. There is no error return.
-------------------------------- Example ---------------------------------
This example makes sure 'string2' is not empty before copying it to
'string1'.
#include <string.h>
#include <stdio.h>
char string1[50];
char string2[50] = "bumble bee";
int len;
main()
{
if ((len = strlen(string2)) > 0)
strcpy(string1,string2);
printf("%s",string1);
}
See Also:
strcpy()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson